export enum ModalOptType {
  ADD = 'add',
  EDIT = 'edit',
  DETAIL = 'detail',
}
export interface BaseModalProps {
  open: boolean
  type?: ModalOptType
  currentId?: string
  params?: any
}

export function useFormModal(props: BaseModalProps, emit: any) {
  const open = useVModel(props, 'open', emit)
  const isAdd = computed(() => props.type === ModalOptType.ADD)
  const isEdit = computed(() => props.type === ModalOptType.EDIT)
  const isDetail = computed(() => props.type === ModalOptType.DETAIL)
  const title = computed(() => {
    switch (props.type) {
      case ModalOptType.ADD:
        return '新增'
      case ModalOptType.EDIT:
        return '编辑'
      case ModalOptType.DETAIL:
        return '详情'
      default:
        return '新增'
    }
  })

  return {
    open,
    isAdd,
    isEdit,
    isDetail,
    title,
  }
}
